package
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.ui.Keyboard;
	
	public class SnakeARI extends Sprite
	{
		private var count:int = 0;
		private var dir:int = 1;
		//		private var op1
		public function SnakeARI()
		{
			addEventListener(Event.ENTER_FRAME,onEnterFrame);
			stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
			
		}
		
		private function onKeyDown(e:KeyboardEvent):void{
			switch(e.keyCode){
				case Keyboard.RIGHT: dir = 0; break;
				case Keyboard.UP: dir = 1; break;
				case Keyboard.LEFT: dir = 2; break;
				case Keyboard.DOWN: dir = 3; break;
			}
		}
		
		private function createOptions():void{
			
		}
		
		private function onEnterFrame(e:Event):void{
			count++;
			if (count==10){
				count = 0;
				var dirX:int = 75*Math.round(Math.cos(Math.PI*dir/2));
				var dirY:int = 75*Math.round(Math.sin(Math.PI*dir/2));
				head.x += dirX;
				head.y -= dirY;
				
			}
		}
	}
}